home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / cmds / pmake.man < prev    next >
Encoding:
Text File  |  1991-10-07  |  50.9 KB  |  1,546 lines

  1. '\" $Id: pmake.man,v 1.7 91/10/06 20:53:56 kupfer Exp $ SPRITE (Berkeley)
  2. .de Pm
  3. .ie \\n(.$ .IR PMake \\$1
  4. .el .I PMake
  5. ..
  6. .if n .nr #D 3n
  7. .if t .nr #D .5i
  8. .if n .ds -> \->
  9. .if t .ds -> \(->
  10. .de DS   \" Real Display-Start macro. It actually works!
  11. .sp .5v
  12. .nf
  13. .in +\\n(#Du
  14. ..
  15. .de DE   \" Real Display-End macro.
  16. .in
  17. .fi
  18. .sp .5v
  19. ..
  20. .so \*(]ltmac.sprite
  21. .HS PMAKE cmds "4 February 1991"
  22. .BS
  23. .SH NAME
  24. pmake \- create programs in parallel
  25. .SH SYNOPSIS
  26. .HP
  27. .fi
  28. .B pmake
  29. [\c
  30. .B \-b\c
  31. ] [\c
  32. .B \-d
  33. .I what\c
  34. ] [\c
  35. .B \-f
  36. .I makefile\c
  37. ] [\c
  38. .B \-h\c
  39. ] [\c
  40. .B \-i\c
  41. ] [\c
  42. .B \-k\c
  43. ] [\c
  44. .B \-l\c
  45. ] [\c
  46. .B \-n\c
  47. ] [\c
  48. .B \-p
  49. .I #\c
  50. ] [\c
  51. .B \-q\c
  52. ] [\c
  53. .B \-r\c
  54. ] [\c
  55. .B \-s\c
  56. ] [\c
  57. .B \-t\c
  58. ] [\c
  59. .B \-v\c
  60. ] [\c
  61. .B \-x\c
  62. ] [\c
  63. .B \-B\c
  64. ] [\c
  65. .B \-C\c
  66. ] [\c
  67. .B \-D
  68. .I variable\c
  69. ] [\c
  70. .B \-I
  71. .I directory\c
  72. ] [\c
  73. .B \-J
  74. .I #\c
  75. ] [\c
  76. .B \-L
  77. .I #\c
  78. ] [\c
  79. .B \-M\c
  80. ] [\c
  81. .B \-P\c
  82. ] [\c
  83. .B \-R\c
  84. ] [\c
  85. .B \-V\c
  86. ] [\c
  87. .B \-W\c
  88. ] [\c
  89. .B \-X\c
  90. ] [\c
  91. .IB VAR1 = value1\c
  92. ] [\c
  93. .IB VAR2 = value2 ...\c
  94. ] [\c
  95. .I targ1\c
  96. ] [\c
  97. .I targ2 ...\c
  98. ]
  99. .BE
  100. .AR
  101. .AS \-I directory
  102. .AP \-b "\&"
  103. ``Background'' -- run all remote processes at low priority.  See also 
  104. the .BACKGROUND attribute.
  105. .AP \-d what
  106. Specify what modules should print debugging information.
  107. .I what
  108. is a string of letters from the following set: 
  109. .B a 
  110. (archives), 
  111. .B c
  112. (conditionals), 
  113. .B d 
  114. (directory searching), 
  115. .B j 
  116. (jobs), 
  117. .B m
  118. (make), 
  119. .B p
  120. (parsing), 
  121. .B r
  122. (remote), 
  123. .B s
  124. (suffixes),
  125. .B t
  126. (targets), 
  127. .B v
  128. (variables).  Use
  129. .B -d jr
  130. to find out what host each job is run on.
  131. .AP \-f makefile
  132. Specify a different makefile to read than the standard
  133. ``Makefile'' or ``makefile''.  If
  134. .I makefile
  135. is "-", reads from standard input.
  136. .AP \-h "\&"
  137. Prints out help information.
  138. .AP \-i "\&"
  139. ``Ignore errors'' -- ignore non-zero exit statuses of commands.
  140. .AP \-k "\&"
  141. ``Keepgoing'' -- if an error is encountered,
  142. keep working on those parts of the input graph that are not affected by the
  143. error.
  144. .AP \-l "\&"
  145. PMake has the ability to lock a directory against other
  146. people executing it in the same directory (by means of a file called
  147. ``LOCK.make'' that it creates and checks for in the directory). This
  148. is a Good Thing because two people doing the same thing in the same place
  149. can be disastrous for the final product (too many cooks and all that).
  150. Whether this locking is the default is up to your system
  151. administrator. If locking is on,
  152. .B \-l
  153. will turn it off, and vice versa. Note that this locking will not
  154. prevent \fIyou\fP from invoking PMake twice in the same place -- if
  155. you own the lock file, PMake will warn you about it but continue to execute.
  156. .AP \-n "\&"
  157. ``No execute'' -- do not execute commands.
  158. Just print the ones that would be executed.
  159. .AP \-p "#"
  160. Tell
  161. .Pm
  162. if and when to print the input graph.
  163. The number is the bitwise OR of the numbers 1 and 2 with 1 meaning to print the
  164. graph before making anything and 2 meaning to print the graph after making
  165. everything.
  166. If no number is given,
  167. it defaults to 3.
  168. .AP \-q "\&"
  169. ``Query'' -- do not execute any commands.
  170. Just exit 0 if the given target(s) is (are) up to date and exit non-zero
  171. otherwise.
  172. .AP \-r "\&"
  173. ``Remove built-in rules'' -- do not parse the built-in rules given in
  174. the system makefile.
  175. .AP \-s "\&"
  176. ``Silence'' -- do not echo commands as they are executed.
  177. .AP \-t "\&"
  178. ``Touch targets'' -- rather than executing the commands to create a target,
  179. just change its modification time so it appears up-to-date.
  180. This is dangerous.
  181. .AP \-v "\&"
  182. ``System V'' -- invokes compatibility functions suitable for acting
  183. like the System V version of Make. This implies
  184. .AP \-x "\&"
  185. ``Export judiciously -- run commands locally in preference to running them 
  186. remotely.  By default, PMake will only run locally
  187. if there are more commands to execute than idle hosts available; with
  188. this option,  
  189. PMake will run one command locally and export additional
  190. commands to available hosts.
  191. .B \-B ,
  192. and
  193. .B \-V 
  194. and turns off directory locking. Locking may be turned back on again
  195. by giving the
  196. .B \-l
  197. flag after
  198. .B \-v .
  199. .AP \-B "\&"
  200. ``Backwards-compatible'' -- performs as much like Make as possible
  201. (including executing a single shell per command and expanding
  202. variables as Make did) while still performing in parallel.
  203. .AP \-C "\&"
  204. ``Non-compatible'' -- turns off all compatibility specified up to the point at
  205. which
  206. .B \-C
  207. is encountered.
  208. .AP \-D variable
  209. Defines the given variable to be
  210. .B 1
  211. in the global context.
  212. .AP \-I directory
  213. Specify another directory in which to look for #include'd makefiles.
  214. This flag may be repeated as many times as necessary.
  215. .AP \-J #
  216. Specify the maximum number of jobs to run at once on all machines.
  217. .AP \-L #
  218. Specify the maximum number of jobs to run locally.
  219. .AP \-M "\&"
  220. Be as much like Make as possible. No parallel execution. Old-style
  221. variable expansion. One shell per command. Etc.
  222. .AP \-P "\&"
  223. ``Don't use Pipes'' -- see the section on
  224. .AP \-R "\&"
  225. ``Remigrate verbosely'' -- announce when processes are remigrated
  226. subsequent to eviction.
  227. .BR OUTPUT .
  228. .AP \-V "\&"
  229. ``Do old-style variable expansion'' -- expands an unknown variable to
  230. the empty string.
  231. .AP \-W "\&"
  232. Don't print warning messages.
  233. .AP \-X "\&"
  234. ``No Export'' -- prohibits exportation. 
  235. .AP VAR=value "\&"
  236. Set the value of the variable
  237. .B VAR
  238. to the given value.
  239. This supercedes any value assigned to the variable in the makefile.
  240. See
  241. .BR VARIABLES .
  242. .SH DESCRIPTION
  243. .PP
  244. .Pm
  245. is a program designed to make the maintenance of other programs much
  246. easier.  Its input is a ``makefile'' that specifies which files depend
  247. on which other files and what to do about files that are
  248. ``out-of-date.''
  249. If you don't specify a makefile to read,
  250. .B Makefile
  251. and
  252. .BR makefile ,
  253. in that order,
  254. are looked for and read if they exist.
  255. .PP
  256. This manual page is meant to be a reference page only. For a more
  257. thorough description of
  258. .Pm ,
  259. please refer to
  260. .I PMake -- A Tutorial\c
  261. (available in this distribution).
  262. .PP
  263. There are four basic types of lines in a makefile:
  264. .RS
  265. .IP 1)
  266. File dependency specifications
  267. .IP 2)
  268. Creation commands
  269. .IP 3)
  270. Variable assignments
  271. .IP 4)
  272. Comments,
  273. include statements and conditional directives
  274. .RE
  275. .PP
  276. Any line may be continued over multiple lines by ending it with a backslash.
  277. The backslash,
  278. following newline and any initial whitespace on the following line are
  279. compressed into a single space.
  280. .SH DEPENDENCY LINES
  281. .PP
  282. On a dependency line, there are targets, sources and an operator.
  283. The targets ``depend'' on the sources and are usually created from them.
  284. Any number of targets and sources may be specified on a dependency
  285. line. All the targets in the line are made to depend on all the sources.
  286. If you run out of room, use a backslash at the end of the line to
  287. continue onto the next one.
  288. .PP
  289. Any file may be a target and any file may be a source, but the relationship
  290. between them is determined by the ``operator''
  291. that separates them. Three operators are defined:
  292. .RS
  293. .IP ":"
  294. A target on the line is considered ``out-of-date''
  295. if any of its sources has been modified
  296. more recently than the target. Sources for a target accumulate over
  297. lines when this operator is used.
  298. .IP "!"
  299. Targets will always be re-created, but this will not happen until all
  300. of its sources have been examined and re-created, if necessary.
  301. Sources accumulate over lines as for the colon.
  302. .IP "::"
  303. Much like the colon, but acts like the ! operator if no sources are
  304. specified. In addition sources do not accumulate over lines. Rather,
  305. the commands associated with the line (see below) are executed only if
  306. the target is out-of-date with respect to the sources on that line only.
  307. In addition, the target will not be removed if
  308. .Pm
  309. is interrupted, unlike for the other two operators.
  310. .RE
  311. .PP
  312. For example:
  313. .DS
  314. a    : a.o b.o c.o
  315. b    ! d.o e.o
  316. c    :: f.o
  317.     command1
  318. a    : g.o
  319. b    ! h.o
  320. c    ::
  321.     command2
  322. .DE
  323. specifies that a depends on a.o, b.o, c.o and g.o and will be remade
  324. only if out-of-date with respect to these four files. b depends on
  325. d.o, e.o and h.o and will always be remade, but only after these three
  326. files have been remade. c will be remade with command1 if it is
  327. out-of-date with respect to f.o, as for the colon operator, while
  328. command2 will always be executed.
  329. .PP
  330. Targets and sources may also contain standard shell wildcard
  331. characters (?, *, [ and {}), but the ?, *, [ and ] characters may only
  332. be used in the final component of the target or source. If a target or
  333. source contains only curly braces and no other wildcard characters, it
  334. need not describe an existing file. Otherwise, only existing files
  335. will be used. E.g. the pattern
  336. .DS
  337. {a,b,c}.o
  338. .DE
  339. will expand to
  340. .DS
  341. a.o b.o c.o
  342. .DE
  343. regardless of whether these three files exist, while
  344. .DS
  345. [abc].o
  346. .DE
  347. will only expand to this if all three files exist. The resulting
  348. expansion is in directory order, not alphabetically sorted as in the shell.
  349. .SH COMMANDS
  350. .PP
  351. Each target has associated with it a sort of shell script made up of a
  352. series of shell commands. The creation script for a target should
  353. immediately follow the dependency line for that target.
  354. Each of the commands in this script
  355. .I must
  356. be preceded by a tab character. 
  357. .PP
  358. While any given target
  359. may appear on more than one dependency line, only one of these dependency lines
  360. may be followed by a creation script, unless the "::" operator is used.
  361. .PP
  362. One helpful feature of
  363. .Pm
  364. is the ability to squirrel away commands for a target to be executed when
  365. everything else has been done. To do this, make one of the commands
  366. for the target be just ``...'' (an ellipsis) on a line by itself. The
  367. ellipsis itself won't be executed, of course, but any commands in the
  368. target's script that follow the ellipsis will be saved until
  369. .Pm
  370. is done processing everything it needs to process.
  371. If you were to say,
  372. .DS
  373. a.o             : a.c
  374.         cc -c a.c
  375.         ...
  376.         @echo "All done"
  377. .DE
  378. Then the command ``echo "All done"'' would execute once everything
  379. else had finished. Note that this will only happen if ``a.o'' is found
  380. to be out-of-date.
  381. .PP
  382. There is another way in which makefile shell commands differ from
  383. regular shell commands, as illustrated in the above makefile scrap.
  384. The first two characters after the initial tab (and any other
  385. whitespace) are treated specially. If they are any combination of `@'
  386. and `\-', (``@'', ``@\-'', ``\-@'' or ``\-''), they cause
  387. .Pm
  388. to do different things.
  389. .PP
  390. In most cases, shell commands are printed to
  391. the screen before they're actually executed. This is to keep you
  392. informed of what's going on. If an `@' appears, however, this echoing
  393. is suppressed. In the case of the echo command, above, this makes
  394. sense. It would look silly to see
  395. .DS
  396. echo "All done"
  397. All done
  398. .DE
  399. so
  400. .Pm
  401. allows you to avoid that (this sort of echo control is
  402. only available if you use the Bourne or C shells to execute your
  403. commands, since the commands are echoed by the shell,
  404. not by
  405. .Pm ).
  406. .PP
  407. The other special character is the `\-'.  Shell commands exit with a
  408. certain ``exit status.''  Normally this status will be 0 if everything
  409. went ok and non-zero if something went wrong. For this reason,
  410. .Pm
  411. will consider an error to have occurred if one of the commands it
  412. invokes returns a non-zero status. When it detects an error, its usual
  413. action is to stop working, wait for everything in process to finish,
  414. and exit with a non-zero status itself.  This behavior can be altered,
  415. however, by means of
  416. .B \-i
  417. or
  418. .B \-k
  419. arguments, or by placing a `\-' at the
  420. front of the command.
  421. (Another quick note: the decision of whether to abort a target when
  422. one of its shell commands returns non-zero is left to the shell that
  423. is executing the commands. Some shells allow this ``error-checking''
  424. to be switched on and off at will while others do not.)
  425. .SH VARIABLES
  426. .PP
  427. .Pm
  428. has the ability to save text in variables to be recalled later at your
  429. convenience.  Variables in
  430. .Pm
  431. are used much like variables in
  432. .IR sh (1)
  433. and, by tradition, consist of all upper-case letters.
  434. They are assigned- and appended-to using lines of the form
  435. .DS
  436. \fIVARIABLE\fP \fB=\fP \fIvalue\fP
  437. \fIVARIABLE\fP \fB+=\fP \fIvalue\fP
  438. .DE
  439. respectively, while being conditionally assigned-to (if not already
  440. defined) and assigned-to with expansion by lines of the form
  441. .DS
  442. \fIVARIABLE\fP \fB?=\fP \fIvalue\fP
  443. \fIVARIABLE\fP \fB:=\fP \fIvalue\fP
  444. .DE
  445. Finally, 
  446. .DS
  447. \fIVARIABLE\fP \fB!=\fP \fIcommand\fP
  448. .DE
  449. will execute
  450. .I command
  451. using the Bourne shell and place the result in the given variable.
  452. Newlines are converted to spaces before the assignment is made. This
  453. is not intended to be used with commands that produce a large amount
  454. of output. If you use it this way, it will probably deadlock.
  455. .PP
  456. Variables are expanded by enclosing the variable name in either
  457. parentheses or curly braces and preceding the whole thing with a
  458. dollar sign.  E.g. to set the variable
  459. .B CFLAGS
  460. to the string ``\-I/sprite/src/lib/libc \-O'' you would place a line
  461. .DS
  462. CFLAGS = \-I/sprite/src/lib/libc \-O
  463. .DE
  464. in the makefile and use the word
  465. .B $(CFLAGS)
  466. wherever you would like the string ``\-I/sprite/src/lib/libc \-O'' to
  467. appear.  To pass a string of the form ``$(\fIname\fP)'' or
  468. ``${\fIname\fP}'' through to the shell (e.g. to tell it to substitute
  469. one of its variables),
  470. you can use ``$$(\fIname\fP)'' and ``$${\fIname\fP}'',
  471. respectively, 
  472. or,
  473. as long as the \fIname\fP is not a
  474. .Pm
  475. variable,
  476. you can just place the string in directly, as
  477. .Pm
  478. will not expand a variable it doesn't know, unless it is given one of
  479. the three compatibility flags
  480. .BR \-V ,
  481. .BR \-B ,
  482. or
  483. .BR \-M .
  484. .PP
  485. There are two distinct times at which variable substitution occurs:
  486. When parsing a dependency line,
  487. such substitution occurs immediately upon reading the line.
  488. Thus all variables used in dependency lines must be defined before
  489. they appear on any dependency line.
  490. For variables that appear in shell commands,
  491. variable substitution occurs when the command is processed,
  492. i.e. when it is prepared to be passed to the shell or before being
  493. squirreled away for later execution (qv. \fBCOMMANDS\fP, above).
  494. .PP
  495. There are four different types of variables at which
  496. .Pm
  497. will look when trying to expand any given variable.
  498. They are (in order of decreasing precedence): (1) variables that are
  499. defined specific to a certain target. These are the so-called
  500. ``local'' variables and will only be used when performing variable
  501. substitution on the target's shell script and in dynamic sources (see below
  502. for more details), (2) variables that were defined on the command line,
  503. (3) variables defined in the makefile and (4) those defined in
  504. .Pm 's
  505. environment, as passed by your login shell.
  506. An important side effect of this searching order is that once you
  507. define a variable on the command line, nothing in the makefile can
  508. change it. \fINothing.\fP
  509. .PP
  510. As mentioned above,
  511. each target has associated with it as many as seven ``local''
  512. variables. Four of these variables are always set for every target
  513. that must be re-created. Each local variable has a long, meaningful
  514. name and a short, one-character name that exists for backwards-compatibility.
  515. They are:
  516. .RS
  517. .IP ".TARGET (@)"
  518. The name of the target.
  519. .IP ".OODATE (?)"
  520. The list of sources for this target that were deemed out-of-date.
  521. .IP ".ALLSRC (>)"
  522. The list of all sources for this target.
  523. .IP ".PREFIX (*)"
  524. The file prefix of the file. This contains only the file portion -- no
  525. suffix or leading directory components.
  526. .RE
  527. .PP
  528. Three other ``local'' variables are set only for certain targets under
  529. special circumstances. These are the ``.IMPSRC'', ``.ARCHIVE''
  530. and ``.MEMBER'' variables. When
  531. they are set, how they are used, and what their short forms are are detailed
  532. in later sections.
  533. .PP
  534. In addition, for you System V fans, the six variables ``@F'', ``@D'',
  535. ``<F'', ``<D'', ``*F'', and ``*D'' are defined to be the same as for the
  536. System V version of Make. If you don't know about these things, be glad.
  537. .PP
  538. Four of these local variables may be used in sources on dependency
  539. lines. The variables expand to the proper value for each target on the
  540. line. The variables are ``.TARGET'', ``.PREFIX'', ``.ARCHIVE'', and
  541. ``.MEMBER''.
  542. .PP
  543. In addition, certain variables are set by or have special meaning to
  544. .Pm .
  545. The
  546. .B .PMAKE
  547. (and
  548. .BR MAKE )
  549. variable is set to the name by which
  550. .Pm
  551. was invoked, to allow recursive makes to use the same version,
  552. whatever it may be.
  553. All command-line flags given to
  554. .Pm
  555. are stored in the
  556. .B .MAKEFLAGS
  557. (and
  558. .BR MFLAGS )
  559. variable just as they were given. This variable is also exported to
  560. subshells as the
  561. .B PMAKE
  562. environment variable.
  563. .PP
  564. Variable expansion may be modified as for the C shell. A general
  565. expansion specification looks like:
  566. .DS
  567. \fB$(\fP\fIvariable\fP[\fB:\fP\fImodifier\fP[\fB:\fP...]]\fB)\fP
  568. .DE
  569. Each modifier begins with a single character, thus:
  570. .RS
  571. .IP "M\fIpattern\fP"
  572. This is used to select only those words (a word is a series of
  573. characters that are neither spaces nor tabs) that match the given
  574. .I pattern .
  575. The pattern is a wildcard pattern like that used by the shell, where "*"
  576. means 0 or more characters of any sort; "?" is any single character;
  577. "[abcd]" matches any single character that is either `a', `b', `c' or `d'
  578. (there may be any number of characters between the brackets);
  579. .B [0-9]
  580. matches any single character that is between `0' and `9' (i.e. any
  581. digit. This form may be freely mixed with the other bracket form), and
  582. \&\e is used to escape any of the characters "*", "?", "[" or ":",
  583. leaving them as regular characters to match themselves in a word.
  584. .IP "N\fIpattern\fP"
  585. This is identical to ":M" except it substitutes all words that don't
  586. match the given pattern.
  587. .IP "S/\fIsearch-string\fP/\fIreplacement-string\fP/[g]"
  588. Causes the first occurrence of
  589. .I search-string
  590. in the variable to be replaced by
  591. .I replacement-string ,
  592. unless the "g"
  593. flag is given at the end, in which case all occurrences of the string
  594. are replaced. The substitution is performed on each word in the
  595. variable in turn. If 
  596. .I search-string
  597. begins with a "^",
  598. the string must match starting at the beginning of the word. If
  599. .I search-string
  600. ends with a "$",
  601. the string must match to the end of the word (these two may be
  602. combined to force an exact match). If a backslash precedes these two
  603. characters, however, they lose their special meaning. Variable
  604. expansion also occurs in the normal fashion inside both the
  605. .I search-string
  606. and the
  607. .I replacement-string ,
  608. .B except
  609. that a backslash is used to prevent the expansion of a "$",
  610. not another dollar sign, as is usual.
  611. Note that
  612. .I search-string
  613. is just a string, not a pattern, so none of the usual
  614. regular-expression/wildcard characters has any special meaning save "^"
  615. and "$".
  616. In the replacement string,
  617. the "&"
  618. character is replaced by the
  619. .I search-string
  620. unless it is preceded by a backslash.
  621. You are allowed to use any character except
  622. colon or exclamation point to separate the two strings. This so-called
  623. delimiter character may be placed in either string by preceding it
  624. with a backslash.
  625. .IP T
  626. Replaces each word in the variable expansion by its last
  627. component (its ``tail''). 
  628. .IP H
  629. This is similar to ":T",
  630. except that every word is replaced by everything but the tail (the
  631. ``head''). 
  632. .IP E
  633. ":E" replaces each word by its suffix (``extension'').
  634. .IP R
  635. This replaces each word by everything but the suffix (the ``root'' of
  636. the word).
  637. .RE
  638. .PP
  639. In addition, PMake supports the System V form of substitution
  640. (\fIstring1\fP=\fIstring2\fP). 
  641. .SH COMMENTS, INCLUSION AND CONDITIONALS
  642. .PP
  643. Makefile inclusion and conditional structures reminiscent of
  644. the C compiler have also been included in
  645. .Pm .
  646. .PP
  647. Comments begin with a `#' anywhere but in a shell command and continue
  648. to the end of the line.
  649. If the `#' comes at the beginning of the line, however, the following
  650. keywords are recognized and acted on:
  651. .SS include ''\fImakefile\fP''
  652. .SS include <\fIsystem makefile\fP>
  653. .PP
  654. This is very similar to the C compiler's file-inclusion facility,
  655. right down to the syntax.  What follows the
  656. .B #include
  657. must be a filename enclosed either in double-quotes or angle brackets.
  658. Variables will be expanded between the double-quotes or
  659. angle-brackets.  If angle-brackets are used, the system makefile
  660. directory is searched.  If the name is enclosed in double-quotes, the
  661. including makefile's directory, followed by all directories given via
  662. .B \-I
  663. arguments, followed by the system directory, is searched for a
  664. file of the given name.
  665. .PP
  666. If the file is found,
  667. .Pm
  668. starts taking input from that file as if it were part of the original
  669. makefile.
  670. .PP
  671. When the end of the file is reached,
  672. .Pm
  673. goes back to the previous file and continues from where it left off.
  674. This facility is recursive up to a depth limited only by the number of open
  675. files allowed to any process at one time.
  676. .SS "if [!] \fIexpr\fP [ \fIop\fP \fIexpr\fP ... ]"
  677. .SS ifdef [!] \fIvariable\fP [\fIop\fP \fIvariable\fP...]
  678. .SS ifndef [!] \fIvariable\fP [\fIop\fP \fIvariable\fP...]
  679. .SS ifmake [!] \fItarget\fP [\fIop\fP \fItarget\fP...]
  680. .SS ifnmake [!] \fItarget\fP [\fIop\fP \fItarget\fP...]
  681. .PP
  682. These are all the beginnings of conditional constructs in the spirit of
  683. the C compiler.
  684. Conditionals may be nested to a depth of thirty.
  685. .PP
  686. In the expressions given above,
  687. .I op
  688. may be either \fB||\fP (logical \s-2OR\s0) or \fB&&\fP (logical
  689. \s-2AND\s0).
  690. .B &&
  691. has a higher precedence than
  692. .BR || .
  693. As in C,
  694. .Pm
  695. will evaluate an expression only as far as necessary to determine its
  696. value. I.e. if the left side of an
  697. .B &&
  698. is false, the expression is false and vice versa for
  699. .BR || .
  700. Parentheses may be used as usual to change the order of evaluation.
  701. .PP
  702. One other boolean operator is provided: \fB!\fP (logical negation). It
  703. is of a higher precedence than either the \s-2AND\s0 or \s-2OR\s0 operators,
  704. and may be applied in any of the ``if'' constructs,
  705. negating the given function for ``#if'' or the implicit function for
  706. the other four.
  707. .PP
  708. .I Expr
  709. can be one of several things. Four functions are provided, each of
  710. which takes a different sort of argument. 
  711. .PP
  712. The function
  713. .B defined
  714. is used to test for the existence of a variable.
  715. Its argument is, therefore, a variable name.
  716. Certain lower-case variable names (e.g. ``sun'', ``unix'' and
  717. ``sprite'') are defined in the system makefile (qv. \fBFILES\fP) to
  718. specify the sort of system on which
  719. .Pm
  720. is being run. These are intended to make makefiles more portable.
  721. Any variable may be used as the argument of the
  722. .B defined
  723. function.
  724. .PP
  725. The
  726. .B make
  727. function is given the name of a target in the makefile and evaluates
  728. to true if the target was given on
  729. .Pm 's
  730. command-line or as a source for the
  731. .B .MAIN
  732. target before the line containing the conditional.
  733. .PP
  734. The
  735. .B exists
  736. function takes a file name, which file is searched for on the system
  737. search path (as defined by
  738. .B .PATH
  739. targets (see below)). It evaluates true if the file is found.
  740. .PP
  741. .B empty
  742. takes a variable expansion specification (minus the dollar sign) as
  743. its argument. If the resulting expansion is empty, this evaluates
  744. true.
  745. .PP
  746. .I Expr
  747. can also be an arithmetic or string comparison, with the lefthand side
  748. being a variable expansion. The standard C relational operators are
  749. allowed, and the usual number/base conversion is performed, with the
  750. exception that octal numbers are not supported. If the righthand side
  751. of a "==" or "!=" operator begins with a quotation mark, a string
  752. comparison is done between the expanded variable and the text between
  753. the quotation marks.  If no relational operator is given, it is
  754. assumed that the expanded variable is to be compared against 0, i.e.
  755. it is interpreted as a boolean, with a 0 value being false and a
  756. non-zero value being true.
  757. .PP
  758. When, in the course of evaluating one of these conditional
  759. expressions,
  760. .Pm
  761. encounters some word it does not recognize, it applies one of either
  762. .I make
  763. or
  764. .I defined
  765. to it, depending on the form of ``if'' used. E.g. ``#ifdef'' will
  766. apply the
  767. .I defined
  768. function, while ``#ifnmake'' will apply the negation of the
  769. .I make
  770. function.
  771. .PP
  772. If the expression following one of these forms evaluates true, the
  773. reading of the makefile continues as before. If it evaluates false,
  774. the following lines are skipped. In both cases, this continues until
  775. either an
  776. .B #else
  777. or an
  778. .B #endif
  779. line is encountered.
  780. .SS else
  781. .PP
  782. The #else,
  783. as in the C compiler,
  784. causes the sense of the last conditional to be inverted and the reading of
  785. the makefile to be based on this new value.
  786. I.e. if the previous expression evaluated true,
  787. the parsing of the makefile is suspended until an #endif line is read.
  788. If the previous expression evaluated false,
  789. the parsing of the makefile is resumed.
  790. .SS "elif [!] \fIexpr\fP [ \fIop\fP \fIexpr\fP ... ]"
  791. .SS elifdef [!] \fIvariable\fP [\fIop\fP \fIvariable\fP...]
  792. .SS elifndef [!] \fIvariable\fP [\fIop\fP \fIvariable\fP...]
  793. .SS elifmake [!] \fItarget\fP [\fIop\fP \fItarget\fP...]
  794. .SS elifnmake [!] \fItarget\fP [\fIop\fP \fItarget\fP...]
  795. .PP
  796. The ``elif'' constructs are a combination of ``else'' and ``if,'' as
  797. the name implies. If the preceding ``if'' evaluated false, the
  798. expression following the ``elif'' is evaluated and the lines following
  799. it are read or ignored the same as for a regular ``if.''
  800. If the preceding ``if'' evaluated true, however, the ``elif'' is
  801. ignored and all following lines until the ``endif'' (see below) are ignored.
  802. .SS endif
  803. .PP
  804. .B #endif
  805. is used to end a conditional section. If lines were being skipped, the
  806. reading of the makefile resumes. Otherwise, it has no effect (the
  807. makefile continues to be parsed as it was just before the
  808. .B #endif
  809. was encountered).
  810. .SS undef
  811. .PP
  812. Takes the next word on the line as a global variable to be undefined
  813. (only undefines global variables, not command-line variables). If the
  814. variable is already undefined, no message is generated.
  815. .SH TARGET ATTRIBUTES
  816. .PP
  817. In
  818. .Pm ,
  819. files can have certain ``attributes.''
  820. These attributes cause
  821. .Pm
  822. to treat the targets in special ways. An attribute is a special word
  823. given as a source to a target on a dependency line. 
  824. The words and their functions are given below:
  825. .nr pw \w'.EXPORTSAME  'u
  826. .IP .BACKGROUND \n(pwu
  827. Forces the target to be run at low priority, to keep it from
  828. preventing other higher-priority processes from using idle hosts.
  829. .IP .DONTCARE \n(pwu
  830. If a target is marked with this attribute and PMake can't figure out
  831. how to create it, it will ignore this fact and assume the file isn't
  832. really needed or actually exists and PMake just can't find it.
  833. .IP .EXEC \n(pwu
  834. This causes the marked target's shell script to always be executed
  835. (unless the
  836. .B \-n
  837. or
  838. .B \-t
  839. flag is given), but appear invisible to any targets that depend on it.
  840. .IP .EXPORT \n(pwu
  841. This is used to mark those targets whose creation should be sent to
  842. another machine if at all possible. This may be used by some
  843. exportation schemes if the exportation is expensive. You should ask
  844. your administrator if it is necessary.
  845. .IP .EXPORTSAME \n(pwu
  846. Tells the export system that the job should be exported to a machine
  847. of the same architecture as the current one. Certain operations (e.g.
  848. running text through
  849. "nroff")
  850. can be performed the same on any architecture (CPU and
  851. operating system type), while others (e.g. compiling a program with
  852. "cc")
  853. must be performed on a machine with the same architecture. Not all
  854. export systems will support this attribute.
  855. .IP .IGNORE \n(pwu
  856. Giving a target the
  857. .B .IGNORE
  858. attribute causes PMake to ignore errors from any of the target's commands, as
  859. if they all had `\-' before them.
  860. .IP .INVISIBLE \n(pwu
  861. This allows you to specify one target as a source for another without
  862. the one affecting the other's local variables.
  863. .IP .JOIN \n(pwu
  864. This forces the target's shell script to be executed only if one or more of the
  865. sources was out-of-date. In addition, the target's name,
  866. in both its
  867. .B .TARGET
  868. variable and all the local variables of any target that depends on it,
  869. is replaced by the value of its
  870. .B .ALLSRC
  871. variable.
  872. Another aspect of the .JOIN attribute is it keeps the target from
  873. being created if the
  874. .B \-t
  875. flag was given.
  876. .IP .MAKE \n(pwu
  877. The
  878. .B .MAKE
  879. attribute marks its target as being a recursive invocation of PMake.
  880. This forces PMake to execute the script associated with
  881. the target (if it's out-of-date) even if you gave the
  882. .B \-n
  883. or
  884. .B \-t
  885. flag.
  886. .IP .NOEXPORT \n(pwu
  887. Forces the target to be created locally, even if you've given
  888. .Pm
  889. the
  890. .B "\-L 0"
  891. flag.
  892. .IP .NOTMAIN \n(pwu
  893. Normally, if you do not specify a target to make in any other way,
  894. .Pm
  895. will take the first target on the first dependency line of a
  896. makefile as the target to create.
  897. Giving a target this attribute keeps it from this fate.
  898. .IP .PRECIOUS \n(pwu
  899. When PMake is interrupted, it
  900. will attempt to clean up after itself by removing any half-made
  901. targets. If a target has this attribute, however,
  902. .Pm
  903. will leave it alone
  904. .IP .SILENT \n(pwu
  905. Marking a target with this attribute keeps its commands from being
  906. printed when they're executed.
  907. .IP .USE \n(pwu
  908. By giving a target this attribute, you turn the target into 
  909. .Pm 's
  910. equivalent of a macro. When the target is used as a source for another target,
  911. the other target acquires the commands, sources and attributes (except
  912. .BR .USE )
  913. of the source.
  914. If the target already has commands, the
  915. .B .USE
  916. target's commands are added to the end. If more than one .USE-marked
  917. source is given to a target, the rules are applied sequentially.
  918. .SH SPECIAL TARGETS
  919. .PP
  920. As there were in Make, so there are certain targets that have special
  921. meaning to PMake. When you use one on a dependency line, it is the
  922. only target that may appear on the left-hand-side of the operator.
  923. The targets are as follows:
  924. .nr pw \w'.MAKEFLAGS  'u
  925. .IP .BACKGROUND \n(pwu
  926. applies the .BACKGROUND attribute to each of its 
  927. sources. If there are no sources on the
  928. dependency line, then it is as if you gave PMake the
  929. .B \-b
  930. flag.
  931. .IP .BEGIN \n(pwu
  932. .Ix 0 def .BEGIN
  933. Any commands attached to this target are executed before anything else
  934. is done. You can use it for any initialization that needs doing.
  935. .IP .DEFAULT \n(pwu
  936. This is sort of a .USE rule for any target (that was used only as a
  937. source) that
  938. .Pm
  939. can't figure out any other way to create. Only the shell script is used. The
  940. .B .IMPSRC
  941. variable of a target that inherits
  942. .B .DEFAULT 's
  943. commands is set to the target's own name.
  944. .IP .END \n(pwu
  945. This serves a function similar to
  946. .BR .BEGIN :
  947. commands attached to it are executed once everything has been
  948. re-created (so long as no errors occurred). It also serves the extra
  949. function of being a place on which PMake can hang commands you put off
  950. to the end. Thus the script for this target will be executed before
  951. any of the commands you save with the ``.\|.\|.''. 
  952. .IP .EXPORT \n(pwu
  953. The sources for this target are passed to the exportation system compiled
  954. into
  955. .Pm .
  956. Some systems will use these sources to configure
  957. themselves. You should ask your system administrator about this.
  958. .IP .IGNORE \n(pwu
  959. This target marks each of its sources with the
  960. .B .IGNORE
  961. attribute. If you don't give it any sources, then it is like
  962. giving the
  963. .B \-i
  964. flag.
  965. .IP .INCLUDES \n(pwu
  966. The sources for this target are taken to be suffixes that indicate a
  967. file that can be included in a program source file.
  968. The suffix must have already been declared with
  969. .B .SUFFIXES
  970. (see below).
  971. Any suffix so marked will have the directories on its search path
  972. (see
  973. .B .PATH ,
  974. below) placed in the
  975. .B .INCLUDES
  976. variable, each preceded by a
  977. .B \-I
  978. flag. 
  979. The
  980. .B .h
  981. suffix is already marked in this way in the system makefile.
  982. .IP .INTERRUPT \n(pwu
  983. When PMake is interrupted,
  984. it will execute the commands in the script for this target, if it
  985. exists. 
  986. .IP .LIBS \n(pwu
  987. This does for libraries what
  988. .B .INCLUDES
  989. does for include files, except the flag used is
  990. .BR \-L ,
  991. as required by those linkers that allow you to tell them where to find
  992. libraries. The variable used is
  993. .BR .LIBS .
  994. .IP .MAIN \n(pwu
  995. If you didn't give a target (or targets) to create when you invoked
  996. PMake, it will take the sources of this target as the targets to
  997. create.
  998. .IP .MAKEFLAGS \n(pwu
  999. This target provides a way for you to always specify flags for PMake
  1000. when the makefile is used. The flags are just as they would be typed
  1001. to the shell,
  1002. though the
  1003. .B \-f
  1004. and
  1005. .B \-r
  1006. flags have no effect.
  1007. .IP .NULL \n(pwu
  1008. This allows you to specify what suffix
  1009. .Pm
  1010. should pretend a file has if, in fact, it has no known suffix. Only
  1011. one suffix may be so designated. The last source on the dependency
  1012. line is the suffix that is used (you should, however, only give one
  1013. suffix.\|.\|.).
  1014. .IP .PATH \n(pwu
  1015. If you give sources for this target, PMake will take them as
  1016. directories to search for files it cannot find in the current
  1017. directory. If you give no sources, it will clear out any directories
  1018. added to the search path before. 
  1019. .IP .PATH\fIsuffix\fP \n(pwu
  1020. This does a similar thing to
  1021. .BR .PATH ,
  1022. but it does it only for files with the given suffix. The suffix must
  1023. have been defined already.
  1024. .IP .PRECIOUS \n(pwu
  1025. Gives the
  1026. .B .PRECIOUS
  1027. attribute to each source on the dependency line, unless there are no
  1028. sources, in which case the
  1029. .B .PRECIOUS
  1030. attribute is given to every target in the file.
  1031. .IP .RECURSIVE \n(pwu
  1032. Applies the
  1033. .B .MAKE
  1034. attribute to all its sources. It does nothing if you don't give it any sources.
  1035. .IP .SHELL \n(pwu
  1036. Tells
  1037. .Pm
  1038. to use some other shell than the Bourne Shell.
  1039. The sources for the target are organized as
  1040. \fIkeyword\fP\fB=\fP\fIvalue\fP strings. If a \fIvalue\fP contains
  1041. whitespace, it may be surrounded by double-quotes to make it a single
  1042. word. The possible sources are:
  1043. .RS
  1044. .IP "\fBpath=\fP\fIpath\fP"
  1045. Tells where the shell actually resides. If you specify this and nothing else, PMake will use the
  1046. last component of the path to find the specification. Use this if you just
  1047. want to use a different version of the Bourne or C Shell (PMake knows
  1048. how to use the C Shell too).
  1049. .IP "\fBname=\fP\fIname\fP"
  1050. This is the name by which the shell is to be known. It is a single
  1051. word and, if no other keywords are specified (other than
  1052. .BR path ),
  1053. it is the name by which PMake attempts to find a specification for the
  1054. it. You can use this if you would just rather use
  1055. the C Shell than the Bourne Shell (``\c
  1056. .BR ".SHELL: name=csh" ''
  1057. will do it).
  1058. .IP "\fBquiet=\fP\fIecho-off command\fP"
  1059. The command
  1060. .Pm
  1061. should send to stop the shell from printing its commands. Once echoing
  1062. is off, it is expected to remain off until explicitly turned on.
  1063. .IP "\fBecho=\fP\fIecho-on command\fP"
  1064. The command PMake should give to turn echoing back on again.
  1065. .IP "\fBfilter=\fP\fIprinted echo-off command\fP"
  1066. Many shells will echo the echo-off command when it is given. This
  1067. keyword tells PMake in what format the shell actually prints the
  1068. echo-off command. Wherever PMake sees this string in the shell's
  1069. output, it will delete it and any following whitespace, up to and
  1070. including the next newline. 
  1071. .IP "\fBechoFlag=\fP\fIflag to turn echoing on\fP"
  1072. The flag to pass to the shell to turn echoing on at the start.  If
  1073. either this or the next flag begins with a `\-', the flags will be
  1074. passed to the shell as separate arguments. Otherwise, the two will be
  1075. concatenated.
  1076. .IP "\fBerrFlag=\fP\fIflag to turn error checking on\fP"
  1077. Flag to give the shell to turn error checking on at the start.
  1078. .IP "\fBcheck=\fP\fIcommand to turn error checking on\fP"
  1079. The command to make the shell check for errors or to print the command
  1080. that's about to be executed (%s indicates where the command to print
  1081. should go), if hasErrCtl is "no".
  1082. .IP "\fBignore=\fP\fIcommand to turn error checking off\fP"
  1083. The command to turn error checking off or the command to execute a
  1084. command ignoring any errors. "%s" takes the place of the command.
  1085. .IP "\fBhasErrCtl=\fP\fIyes or no\fP"
  1086. This takes a value that is either
  1087. .B yes
  1088. or
  1089. .BR no ,
  1090. telling how the "check" and "ignore" commands should be used.
  1091. NOTE: If this is "no", both the check and ignore commands should
  1092. contain a \en at their end if the shell requires a newline before
  1093. executing a command.
  1094. .RE
  1095. .IP "\&" \n(pwu
  1096. The strings that follow these keywords may be enclosed in single or
  1097. double quotes (the quotes will be stripped off) and may contain the
  1098. usual C backslash-characters.
  1099. .IP .SILENT \n(pwu
  1100. Applies the
  1101. .B .SILENT
  1102. attribute to each of its sources. If there are no sources on the
  1103. dependency line, then it is as if you gave PMake the
  1104. .B \-s
  1105. flag.
  1106. .IP .SUFFIXES \n(pwu
  1107. This is used to give new file suffixes for PMake to handle. Each
  1108. source is a suffix PMake should recognize. If you give a
  1109. .B .SUFFIXES
  1110. dependency line with no sources, PMake will forget about all the
  1111. suffixes it knew (this also nukes the null suffix).
  1112. For those targets that need to have suffixes defined, this is how you do it.
  1113. .PP
  1114. In addition to these targets, a line of the form
  1115. .DS
  1116. \fIattribute\fP : \fIsources\fP
  1117. .DE
  1118. applies the
  1119. .I attribute
  1120. to all the targets listed as
  1121. .I sources
  1122. except as noted above.
  1123. .SH THE POWER OF SUFFIXES
  1124. .PP
  1125. One of the best aspects of both
  1126. .I Make
  1127. and
  1128. .Pm
  1129. comes from their understanding of how the suffix of a file pertains to
  1130. its contents and their ability to do things with a file based solely on its
  1131. suffix.
  1132. .Pm
  1133. also has the ability to find a file based on its suffix,
  1134. supporting different types of files being in different directories.
  1135. The former ability derives from the existence of so-called
  1136. transformation rules while the latter comes from the specification of
  1137. search paths using the
  1138. .B .PATH
  1139. target.
  1140. .SS TRANSFORMATION RULES
  1141. .PP
  1142. A special type of dependency, called a transformation rule, consists
  1143. of a target made of
  1144. two known suffixes stuck together followed by a shell script to transform a
  1145. file of one suffix into a file of the other.
  1146. The first suffix is the suffix of the source file and the second is that of
  1147. the target file.
  1148. E.g. the target ``.c.o,'' followed by commands,
  1149. would define a transformation from files with the
  1150. ``.c'' suffix to those with the ``.o'' suffix.
  1151. A transformation rule has no source files associated with it, though
  1152. attributes may be given to one in the usual way. These attributes are
  1153. then applied to any target that is on the ``target end'' of a
  1154. transformation rule.
  1155. The suffixes that are concatenated must be already known to
  1156. .Pm
  1157. in order for their concatenation to be recognized as a transformation,
  1158. i.e. the suffixes must have been the source for a .SUFFIXES target at some
  1159. time before the transformation is defined.
  1160. Many transformations are defined in the system makefile (qv.
  1161. .BR FILES )
  1162. and I refer you there for more examples as well as to find what is
  1163. already available (you should especially note the various variables
  1164. used to contain flags for the compilers, assemblers, etc., used to
  1165. transform the files. These variables allow you to customize the
  1166. transformations to your own needs without having to redefine them).
  1167. A transformation rule may be defined more than once, but only the last
  1168. such definition is remembered by
  1169. .Pm .
  1170. This allows you to redefine the transformations in the system makefile if
  1171. you wish.
  1172. .PP
  1173. Transformation rules are used only when a target has no commands associated
  1174. with it,
  1175. both to find any additional files on which it depends and to attempt to
  1176. figure out just how to make the target should it end up being out-of-date.
  1177. When a transformation is found for a target, another of the seven ``local''
  1178. variables mentioned earlier is defined:
  1179. .RS
  1180. .IP ".IMPSRC (<)"
  1181. The name/path of the source from which the target is to be transformed (the
  1182. ``implied'' source).
  1183. .RE
  1184. .PP
  1185. For example,
  1186. given the following makefile:
  1187. .DS
  1188. a.out : a.o b.o
  1189.     $(CC) $(.ALLSRC)
  1190. .DE
  1191. and a directory containing the files a.o, a.c and b.c,
  1192. .Pm
  1193. will look at the list of suffixes and transformations given in the
  1194. built-in rules and find that the suffixes ``.c'' and ``.o'' are both
  1195. known and there is a transformation rule defined from one to the other
  1196. with the command ``$(CC) $(CFLAGS) -c $(.IMPSRC).''  Having found
  1197. this, it can then check the modification times of both a.c and b.c and
  1198. execute the command from the transformation rule as necessary in order
  1199. to update the files a.o and b.o.
  1200. .PP
  1201. .Pm ,
  1202. unlike
  1203. .I Make
  1204. before it,
  1205. has the ability to apply several transformations to a file even if the
  1206. intermediate files do not exist.
  1207. Given a directory containing a .o file and a .q file, and transformations
  1208. from .q to .l, .l to .c and .c to .o,
  1209. .Pm
  1210. will define a transformation from .q \*(-> .o using the three transformation
  1211. rules you defined.
  1212. In the event of two paths between the same suffixes, the shortest path will be
  1213. chosen between the target and the first existing file on the path.
  1214. So if there were also a transformation from .l files to .o files,
  1215. .Pm
  1216. would use the path .q \*(-> .l \*(-> .o instead
  1217. of .q \*(-> .l \*(-> .c \*(-> .o.
  1218. .PP
  1219. Once an existing file is found,
  1220. .Pm
  1221. will continue to look at and record transformations until it comes to a
  1222. file to which nothing it knows of can be transformed,
  1223. at which point it will stop looking and use the path it has already found.
  1224. .PP
  1225. What happens if you have a .o file, a .q file and a .r file, all with
  1226. the same prefix, and transformations from .q \*(-> .o and .r \*(-> .o?
  1227. Which transformation will be used?
  1228. .Pm
  1229. uses the order in which the suffixes were given on the
  1230. .B .SUFFIXES
  1231. line to decide between transformations: whichever suffix came first,
  1232. wins.
  1233. So if the three suffixes were declared
  1234. .DS
  1235. \&.SUFFIXES : .o .q .r
  1236. .DE
  1237. the .q \*(-> .o transformation would be applied. Similarly, if they were
  1238. declared as
  1239. .DS
  1240. \&.SUFFIXES : .o .r .q
  1241. .DE
  1242. the .r \*(-> .o transformation would be used.
  1243. You should keep this in mind when writing such rules.
  1244. Note also that because the placing of a suffix on a
  1245. .B .SUFFIXES
  1246. line doesn't alter the precedence of previously-defined
  1247. transformations,
  1248. it is sometimes necessary to clear the whole lot of them out and start
  1249. from scratch. This is what the
  1250. .BR .SUFFIXES -only
  1251. line, mentioned earlier, will do.
  1252. .SH SEARCH PATHS
  1253. .PP
  1254. .Pm
  1255. also supports the notion of multiple directories in a more flexible,
  1256. easily-used manner than has been available in the past.
  1257. You can define a list of directories in which to search for any and
  1258. all files that aren't in the current directory by giving the directories
  1259. as sources to the
  1260. .B .PATH
  1261. target. The search will only be conducted for those files used only as
  1262. sources, on the assumption that files used as targets will be created
  1263. in the current directory.
  1264. .PP
  1265. The line
  1266. .DS
  1267. \&.PATH : RCS
  1268. .DE
  1269. would tell
  1270. .Pm
  1271. to look for any files it is seeking (including ones made up by means
  1272. of transformation rules) in the RCS directory as well as the current
  1273. one. Note, however, that this searching is only done if the file is
  1274. used only as a source in the makefile. I.e. if the file cannot be
  1275. created by commands in the makefile.
  1276. .PP
  1277. A search path specific to files with a given suffix can also be
  1278. specified in much the same way.
  1279. .DS
  1280. \&.PATH.h : h /sprite/lib/include
  1281. .DE
  1282. causes the search for header files to be conducted in the h and
  1283. /sprite/lib/include directory as well as the current one.
  1284. .PP
  1285. When expanding wildcards, these paths are also used. If the pattern
  1286. has a recognizable suffix, the search path for that suffix is used.
  1287. Otherwise, the path defined with the regular
  1288. .B .PATH
  1289. target is used.
  1290. .PP
  1291. When a file is found somewhere other than the current directory, its
  1292. name is replaced by its full pathname in any ``local'' variables.
  1293. .PP
  1294. Two types of suffixes are given special attention when a search path is defined
  1295. for them. On most systems, the C compiler lets you specify where to
  1296. find header files (.h files) by means of
  1297. .B \-I
  1298. flags similar to those used by
  1299. .Pm .
  1300. If a search path is given for any suffix used as a source for the
  1301. .B .INCLUDES
  1302. target, the variable
  1303. .B $(.INCLUDES)
  1304. will be set to contain all the directories on the path, in the order
  1305. given, in a format which can be passed directly to the C compiler.
  1306. Similarly, on some systems, one may give directories to search for
  1307. libraries to the compiler by means of
  1308. .B \-L
  1309. flags.
  1310. Directories on the search path for a suffix which was the source of the
  1311. .B .LIBS
  1312. target will be placed
  1313. in the
  1314. .B $(.LIBS)
  1315. variable ready to be passed to the compiler.
  1316. .SH LIBRARIES AND ARCHIVES
  1317. .PP
  1318. Two other special forms of sources are recognized by
  1319. .Pm .
  1320. Any source that begins with the characters ``-l'' or ends in a suffix
  1321. that is a source for the
  1322. .B .LIBS
  1323. target is assumed to be a library, and any source that contains a left
  1324. parenthesis in it is considered to be a member (or members) of an archive.
  1325. .PP
  1326. Libraries are treated specially mostly in how they appear in the local
  1327. variables of those targets that depend on them. If the system supports the
  1328. .B \-L
  1329. flag when linking, the name of the library (i.e. its ``-l'' form) is
  1330. used in all local variables.
  1331. .Pm
  1332. assumes that you will use the $(.LIBS) variable in the appropriate place.
  1333. If, however, the system does not have this feature, the name is
  1334. expanded to its full pathname before it is placed in any local
  1335. variable.
  1336. .PP
  1337. One problem with libraries is they have a table of contents in them
  1338. and when the file is touched (so the file's modification time and the
  1339. time listed in the table of contents don't match), the library is
  1340. declared to be ``out-of-date'' by the linker and the final linking
  1341. stage of creating your program fails miserably. To avoid this problem,
  1342. when you use the
  1343. .B \-t
  1344. flag,
  1345. .Pm
  1346. updates the time of the table of contents for the library, as well as
  1347. the library itself.
  1348. .PP
  1349. The process of creating a library or archive can be a painful one,
  1350. what with all the members having to be kept outside the archive as
  1351. well as inside it in order to keep them from being recreated.
  1352. .Pm
  1353. has been set up, however, to allow you to reference files that are in
  1354. an archive in a relatively painless manner.
  1355. The specification of an archive member is written as:
  1356. .DS
  1357. \fIarchive\fP(\fImember\fP [\fImember\fP...])
  1358. .DE
  1359. Both the open and close parenthesis are required and there may be any
  1360. number of members between them (except 0, that is). Members may also
  1361. include wildcards characters.  When such a source is examined, it is
  1362. the modification time of the member, as recorded in the archive, that
  1363. is used to determine its datedness.
  1364. .PP
  1365. If an archive member has no commands associated with it,
  1366. .Pm
  1367. goes through a special process to find commands for it.
  1368. First, implicit sources are sought using the ``member'' portion of the
  1369. specification. So if you have something like
  1370. ``libcompat.a(procFork.o)'' for a target,
  1371. .Pm
  1372. attempts to find sources for the file ``procFork.o,'' even if it
  1373. doesn't exist. If such sources exist,
  1374. .Pm
  1375. then looks for a transformation rule from the member's suffix to the
  1376. archive's (in this case from .o \*(-> .a) and tacks those commands on
  1377. as well.
  1378. .PP
  1379. To make these transformations easier to write,
  1380. three local variables are defined for the target:
  1381. .IP ".ARCHIVE (%)
  1382. The path to the archive file.
  1383. .IP ".MEMBER (!)
  1384. The actual member name (literally the part in parentheses).
  1385. .IP ".TARGET (@)
  1386. The path to the file which will be archived, if it is only a source,
  1387. or the same as the 
  1388. .B .MEMBER
  1389. variable if it is also a target.
  1390. .PP
  1391. Using the transformations already in the system makefile, a makefile
  1392. for a library might look something like this:
  1393. .DS
  1394. OBJS = procFork.o procExec.o procEnviron.o fsRead.o
  1395. \&.o.a :
  1396.     ...
  1397.     rm -f $(.MEMBER)
  1398.  
  1399. lib.a : lib.a($(OBJS))
  1400.     ar cru $(.TARGET) $(.OODATE)
  1401.     ranlib $(.TARGET)
  1402. .DE
  1403. .PP
  1404. You might be wondering,
  1405. at this point,
  1406. why I did not define the .o \*(-> .a transformation like this:
  1407. .DS
  1408. \&.o.a :
  1409.     ar r $(.ARCHIVE) $(.TARGET)
  1410.     ...
  1411.     rm -f $(.TARGET)
  1412. .DE
  1413. The reason is simple: you cannot execute ``ar'' on the same file
  1414. several times at once. If you try, you end up with a corrupted
  1415. archive.
  1416. So rather than reduce
  1417. .Pm
  1418. to executing only one job at a time, I chose to archive all the
  1419. out-of-date files at once (this turns out to be faster anyway).
  1420. .SH OUTPUT
  1421. .PP
  1422. When creating targets in parallel,
  1423. several shells are executing at once,
  1424. each wanting to write its own two cent's worth onto the screen.
  1425. This output must be captured by
  1426. .Pm
  1427. in some way in order to prevent the screen from being filled with
  1428. garbage even more indecipherable than one can already get from these programs.
  1429. .Pm
  1430. has two ways of doing this,
  1431. one of which provides for much cleaner output and a clear delineation between
  1432. the output of different jobs,
  1433. the other of which provides a more immediate response so one can tell what is
  1434. really happening.
  1435. The former is done by notifying the user when the creation of a given target
  1436. starts, capturing the output, and transferring it
  1437. to the screen when the job finishes,
  1438. preceded by an indication as to which job produced the output.
  1439. The latter is done by catching the output of the shell (and its children)
  1440. and buffering it until an entire line is received, then printing
  1441. that line preceded by the name of the job from which the line came.
  1442. The name of the job is just the target which is being created by it.
  1443. Since I prefer this second method,
  1444. it is the one used by default.
  1445. The first method will be used if the
  1446. .B \-P
  1447. flag is given to
  1448. .Pm .
  1449. .SH PARALLELISM
  1450. .PP
  1451. As mentioned before,
  1452. .Pm
  1453. attempts to create several targets at once.
  1454. On some systems where load balancing or process migration is in
  1455. effect, the amount of concurrency which can be used will be much
  1456. greater than on others. During the development of
  1457. .Pm ,
  1458. I found that while one could create up to five targets at once on a
  1459. Sun 3 without making the machine unusable, attempting the same feat
  1460. on a Sun 2 would grind the machine into the dirt, most likely making
  1461. the whole process run slower than it would have under
  1462. .IR Make .
  1463. In addition, the use of
  1464. .Pm
  1465. on a multi-user machine (in contrast to a workstation) calls for
  1466. judicious use of concurrency to avoid annoying the other users. The
  1467. ability to execute tasks in parallel, in combination with the
  1468. execution of only one shell per target, brings about decreases in
  1469. creation time on the order of 25%\-60%.
  1470. .PP
  1471. The
  1472. .B \-J
  1473. and
  1474. .B \-L
  1475. flags are used to control the number of shells executing at once and
  1476. should be used to find the best level for your machine. Once this is
  1477. found, the default level can be set at that point and
  1478. .Pm
  1479. recompiled.
  1480. .SH BACKWARD-COMPATIBILITY
  1481. .PP
  1482. .Pm
  1483. was designed to be as backwards-compatible with
  1484. .I Make
  1485. as possible.
  1486. In spite of this, however, there are a few major differences which may
  1487. cause problems when using old makefiles:
  1488. .IP 1)
  1489. The variable substitution, as mentioned earlier, is very different and
  1490. will cause problems unless the makefile is converted or the
  1491. .B \-V
  1492. flag is given.
  1493. .IP 2)
  1494. Because targets are created in parallel, certain sequences which
  1495. depend on the sources of a target being created sequentially will fail
  1496. miserably. E.g.:
  1497. .DS
  1498. prod : $(PROGRAM) clean
  1499. .DE
  1500. This is liable to cause some of the object files to be removed after
  1501. having been created during the current invocation (or, at the very
  1502. least, the object files will not be removed when the program has been
  1503. made), leading to errors in the final linking stage. This problem
  1504. cannot even be gotten around by limiting the maximum concurrency to
  1505. one, since the traversal of the dependency graph is done in a
  1506. breadth-first, rather than a depth-first way. This can only be gotten
  1507. around by rewriting the makefile, or by invoking
  1508. .Pm
  1509. with the
  1510. .B \-M
  1511. flag.
  1512. .PP
  1513. One other possible conflict arises because
  1514. .Pm
  1515. forks only one shell to execute the commands to re-create a target.
  1516. This means that changes of directory, environment, etc., remain in
  1517. effect throughout the creation process. It also allows for a more
  1518. natural entry of shell constructs, such as the ``for'' and ``while''
  1519. loops in the Bourne shell, without the need for backslashes and
  1520. semi-colons required by the one-shell-per-command paradigm used by
  1521. .IR Make .
  1522. This shouldn't pose any serious difficulties (or even any trivial ones
  1523. so far as I can see), but should,
  1524. in fact,
  1525. make life a little easier. It is, however, possible to have
  1526. .Pm
  1527. execute each command in a single shell by giving it the
  1528. .B \-B
  1529. flag.
  1530. .SH FILES
  1531. .ta \w'/sprite/lib/pmake/sys.mk  'u
  1532. Makefile or makefile    default input file
  1533. .br
  1534. /sprite/lib/pmake/sys.mk    System makefile (the built-in rules)
  1535. .SH ENVIRONMENT
  1536. .ta \w'\fBPMAKE\fP    'u
  1537. \fBPMAKE\fP    Flags PMake should always use when invoked.
  1538. .SH SEE ALSO
  1539. .IR make (1)
  1540. for a more complete explanation of the lower-case flags to
  1541. .Pm .
  1542. .SH KEYWORDS
  1543. make, transformation
  1544. .SH AUTHOR
  1545. Adam de Boor
  1546.